#ifndef __MP_TCP_CLIENT_H__
#define __MP_TCP_CLIENT_H__

#include "net_base.h"
#include "eventloop.h"
#include "tcp_client_context.h"

namespace Gazella {

class TcpClient: public NetBase {
public:
    TcpClient();
    virtual ~TcpClient();

    //init
    int init(std::string host, int port) override;

protected:
    ev::timer m_timer;

    std::shared_ptr<TcpClientContext> m_context;

    int  __create_tcp_client(std::string host, int port);
    void __delete_tcp_client();

private:
    void __reconnect_timer(ev::timer &w, int revents);

    void __recv_cb(ev::io &w, int revents) override;
    void __send_cb(ev::io &w, int revents) override;

    virtual void __connect_callback();
    virtual void __disconnect_callback();
};
}

#endif